/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
// l8scrn.hpp - Linear screen driver for 8-bpp (256 color) operation.
//
// Author: Kenneth G. Maxwell
//
// Copyright (c) 1997-2008 Swell Software 
//              All Rights Reserved.
//
// Unauthorized redistribution of this source code, in whole or part,
// without the express written permission of Swell Software
// is strictly prohibited.
//
// Notes:
//
//  This screen driver is intended for use with 256-color systems that support
//  a linear frame buffer. Example controllers include the SMOS 135xx series
//  and the MPC823.
//
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

#ifndef _L8SCREEN_
#define _L8SCREEN_

                     
/*--------------------------------------------------------------------------*/
#ifndef PEG_PLOTPOINTVIEW_AS_FUNCTION
 #ifndef CUSTOM_PLOTPOINT_MACRO
  #define PlotPointView(x, y, c) \
        *(SCANLINESTART(y) + x) = (PEGUBYTE) c;
 #endif
#endif


/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
class L8Screen : public PegScreen
{
    public:
        L8Screen(const PegRect &);
        virtual ~L8Screen();

        virtual void Capture(PegCapture *Info, PegRect &Rect);

        virtual PEGUBYTE *GetPalette(PEGULONG *pPutSize);

       #ifdef PEG_IMAGE_SCALING
        virtual PEGCOLOR GetBitmapPixel(PEGINT x, PEGINT y, PegBitmap *pMap)
        {
            PEGCOLOR *pGet = pMap->pStart;
            pGet += pMap->Width * y;
            pGet += x;
            return *pGet;
        }
       #endif

        virtual PEGCOLOR GetPixelView(PEGINT x, PEGINT y)
        {
            if (mpContext)
            {
                return((PEGCOLOR) *(SCANLINESTART(y) + x));
            }
            else
            {
                return 0;
            }
        }

       #ifdef PEG_IMAGE_SCALING
        virtual void PutBitmapPixel(PEGINT x, PEGINT y, PegBitmap *pMap, 
                                    PEGCOLOR Val)
        {
            PEGCOLOR *pPut = pMap->pStart;
            pPut += pMap->Width * y;
            pPut += x;
            *pPut = Val;
        }
       #endif

        virtual void ResetPalette(void);
        virtual void SetPalette(PEGINT First, PEGINT Num, 
                                const PEGUBYTE *pGet);

    protected:

       #ifdef PEG_AA_LINE
        virtual void AALineView(PEGINT xStart, PEGINT yStart, PEGINT xEnd, 
                                PEGINT yEnd, const PegRect& View,
                                PegBrush &Brush);
       #endif

        virtual void BitmapView(const PegPoint Where, 
                                const PegBitmap *pGetmap, 
                                const PegRect &View);

       #ifdef PEG_AA_FONT
        virtual void DrawAliasedText(PegPoint Where, const PEGCHAR *pText, 
                                     PegBrush &Brush, const PegFont *pFont, 
                                     PEGINT Count, PegRect &Rect);
       #endif

       #ifdef PEG_OUTLINE_FONT
        virtual void DrawOutlineText(PegPoint Where, const PEGCHAR *pText, 
                                     PegBrush &Brush, const PegFont *pFont, 
                                     PEGINT Count, PegRect &Rect);
       #endif

        virtual void DrawRleBitmap(const PegPoint Where, const PegRect View,
                                   const PegBitmap *pGetmap);
        virtual void DrawTextView(PegPoint Where, const PEGCHAR *pText, 
                                  PegBrush &Brush, const PegFont *pFont, 
                                  PEGINT Count, PegRect &Rect);

        virtual PEGUBYTE *GetVideoAddress(void);
        virtual void HorizontalLine(PEGINT XStart, PEGINT XEnd, PEGINT YPos,
                                    PEGCOLOR Color, PEGINT Width);
        virtual void HorizontalLineXOR(PEGINT XStart, PEGINT XEnd, 
                                       PEGINT YPos);
       #ifdef PEG_BIDI_SUPPORT
        virtual PEGINT LatinTextLength(PEGCHAR *pText);
       #endif
        virtual void LineView(PEGINT xStart, PEGINT yStart, PEGINT xEnd, 
                              PEGINT yEnd, PegRect &Rect, PegBrush &Brush);

        virtual void PlotSubPixel(PegFixed xVal, PegFixed yVal,
            PEGCOLOR Color) {}

        virtual void RectMoveView(const PegRect &View,
                                  const PEGINT xMove, const PEGINT yMove);
        virtual void VerticalLine(PEGINT YStart, PEGINT YEnd, PEGINT XPos,
                                  PEGCOLOR Color, PEGINT Width);
        virtual void VerticalLineXOR(PEGINT YStart, PEGINT YEnd, PEGINT XPos);

        PEGUBYTE mPalette[768];

};

#endif



